added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2010 / CSWebBrowserWithProxy / Readme.txt
blob59fafa7fdfc0c66756a903c3e61c6a85bec2160a
1 ================================================================================
2        Windows APPLICATION: CSWebBrowserWithProxy Overview                        
3 ===============================================================================
5 /////////////////////////////////////////////////////////////////////////////
6 Summary:
8 The sample demonstrates how to make WebBrowser use a proxy server.
10 In Internet Explorer 5 and later, Internet options can be set for on a specific 
11 connection and process, for example, LAN connection or ADSL connection. Wininet.dll 
12 contains 4 extern methods (InternetOpen, InternetCloseHandle, InternetSetOption 
13 and InternetQueryOption) to set and retrieve internet settings.
16 /////////////////////////////////////////////////////////////////////////////
17 Demo:
19 Step1. Build this project in VS2010. 
21 Step2. Set the proxy servers in ProxyList.xml.
22        The schema is like  
23            <ProxyList>
24                         <Proxy>
25                                 <ProxyName>Proxy Name</ProxyName>
26                                 <Address>Proxy url</Address>
27                                 <UserName></UserName>
28                                 <Password></Password>
29                         </Proxy> 
30                 </ProxyList> 
31                 If the proxy server needs credential, UserName and Password should be specified.
33 Step3. Run CSWebBrowserWithProxy.exe.
35 Step4. Type http://www.whatsmyip.us/ in the top text box, or any web page that could display
36        your IP.
38 Step5. Check "No Proxy" and click Go. The browser shows your real IP.
40 Step6. Check "Proxy Server", choose a Proxy Server in the combo box and click Go. The browser 
41        shows your IP through the Proxy.
44 /////////////////////////////////////////////////////////////////////////////
45 Code Logic:
47 1. Wrap 4 extern methods (InternetOpen, InternetCloseHandle, 
48    InternetSetOption and InternetQueryOption) of wininet.dll, design the 
49    structure and initialize the constants used by them.
51 2. Use class WinINet to set proxy, or restore to system internet options.
52        
53 3. The class WebBrowserControl inherits WebBrowser class and has a feature to 
54    set proxy server.  If the Proxy property is changed, it will call methods 
55    of the WinINet class to set the new proxy.
57 4. Initializes the proxy servers in ProxyList.xml when this application starts. 
59 5. Set the proxy of the web browser when the "Go" button was clicked and 
60    navigate to the URL.
63 /////////////////////////////////////////////////////////////////////////////
64 References:
66 InternetOpen Function
67 http://msdn.microsoft.com/en-us/library/aa385096(VS.85).aspx
69 InternetCloseHandle Function
70 http://msdn.microsoft.com/en-us/library/aa384350(VS.85).aspx
72 InternetSetOption Function
73 http://msdn.microsoft.com/en-us/library/aa385114(VS.85).aspx
75 InternetQueryOption Function
76 http://msdn.microsoft.com/en-us/library/aa385101(VS.85).aspx
78 Setting and Retrieving Internet Options
79 http://msdn.microsoft.com/en-us/library/aa385384(VS.85).aspx
81 How To: Set the proxy for the WebBrowser control in .NET
82 http://blogs.msdn.com/b/jpsanders/archive/2011/04/26/how-to-set-the-proxy-for-the-webbrowser-control-in-net.aspx
85 /////////////////////////////////////////////////////////////////////////////